﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ITunesSolver.Helpers;
using ITunesSolver.Helpers.DataVirtualization;
using ITunesSolver.Data;

namespace ITunesSolver.UI
{
    /// <summary>
    /// Interaction logic for TracksGrid.xaml
    /// </summary>
    public partial class TracksGrid : UserControl
    {
        private SongProvider songProvider;

        public TracksGrid()
        {
            InitializeComponent();
        }

        public void Initialize(HashSet<Song> songs)
        {
            lvTracks.SelectedIndex = 0;
            lvTracks.ItemsSource = null;

            if (songs == null) return;

            songProvider = new SongProvider(songs);
            AsyncVirtualizingCollection<Song> vSongs = new AsyncVirtualizingCollection<Song>(songProvider, 30 /*page size*/, 30000 /*timeout*/);
            //lvTracks.DataContext = vSongs;
            lvTracks.ItemsSource = vSongs;
        }
    }
}
